﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Fiche_Personnes
{
	/// <summary>
	/// Logique d'interaction pour MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			this.InitializeComponent();
			// Insérez le code requis sur la création de l'objet à partir de ce point.
            this.BaseProgramme = new BaseDonnees();
            this.chargementBase();
		}
        private void chargementBase()
        {
            this.personnesDansBase.Children.RemoveRange(0, this.personnesDansBase.Children.Count);
            foreach(Personne p in this.BaseProgramme.Personnes)
            {
                Button b = new Button() { Content = p.Nom, Name = p.Nom.Replace(' ', '_') };
                b.Click += new RoutedEventHandler(boutonPersonneClick);
                this.personnesDansBase.Children.Add(b);
            }
        }

        void boutonPersonneClick(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;
            Personne pClick = this.BaseProgramme.getPersonne(b.Content.ToString());
            // Call new fenetre sur personne
        }

        private BaseDonnees BaseProgramme;

        private void ajouterPersonneClick(object sender, RoutedEventArgs e)
        {
            throw new NotImplementedException();
        }

        private void impression(object sender, RoutedEventArgs e)
        {

        }
	}
}